/*
 * AlbumDialog.java
 *
 * Created on October 19, 2008, 9:26 AM
 */
package com.bff.mpd.musicjukebox.ui;

import com.bff.mpd.musicjukebox.ui.components.MusicJDialog;
import com.bff.mpd.utils.Utils;
import java.awt.Dimension;
import java.text.MessageFormat;
import javax.swing.JDialog;
import org.bff.javampd.objects.MPDArtist;

/**
 *
 * @author  Bill
 */
public class ArtistDialog extends MusicJDialog {

    private final SplashScreen sp;

    /** Creates new form AlbumDialog */
    public ArtistDialog(final java.awt.Frame parent, final MPDArtist artist) {
        super(parent);

        final JDialog dialog = this;

        sp = new SplashScreen(Utils.getParentComponent(this), false);
        sp.setIndeterminate(true);
        sp.setTitleLabel(Utils.getMessage("PROGRESS_LOADING_ARTIST"));
        sp.setMainTextArea("\n" + java.text.MessageFormat.format(Utils.getMessage("PROGRESS_LOADING_ARTIST_TEXT"), new Object[] {artist.getName()}) + "\n\n");
        sp.setProgressBarLabel(Utils.getMessage("PROGRESS_LOADING_ARTIST_LABEL"));
        sp.pack();

        new Thread(new Runnable() {

            @Override
            public void run() {
                try {
                    initComponents();
                    getSongPanel().setArtistSongs(artist);
                     setTitle(MessageFormat.format(Utils.getMessage("ARTIST_DIALOG_TITLE"),new Object[] {artist.getName()}));
                    setSize(new Dimension(750, 500));

                    Utils.centerInParent(dialog, parent);

                    sp.setStopped(true);
                    setVisible(true);
                } finally {
                    if (!sp.isStopped()) {
                        sp.setStopped(true);
                    }
                }
            }
        }).start();

    }

    private SongListTablePanel getSongPanel() {
        return (SongListTablePanel) songListTablePanel;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btnPanel = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        songListTablePanel = new SongListTablePanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jButton1.setText(Utils.getMessage("DIALOG_CLOSE")); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        btnPanel.add(jButton1);

        getContentPane().add(btnPanel, java.awt.BorderLayout.SOUTH);
        getContentPane().add(songListTablePanel, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    dispose();
}//GEN-LAST:event_jButton1ActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel btnPanel;
    private javax.swing.JButton jButton1;
    private javax.swing.JPanel songListTablePanel;
    // End of variables declaration//GEN-END:variables
}
